package thirdwork.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import thirdwork.dao.EmployeeDao;
import thirdwork.dao.impl.EmployeeImpl;

/**
 * Servlet implementation class DeleteEmployee
 */
@WebServlet("/DeleteEmployee")
public class DeleteEmployee extends HttpServlet {
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("UTF-8");
		resp.setContentType("text/html;charset=UTF-8");
		resp.setCharacterEncoding("UTF-8");
		String id = req.getParameter("empid");
		int eid = Integer.parseInt(id);
		EmployeeDao empdao = new EmployeeImpl();
		int a = empdao.deleteEmp(eid);
		System.out.println("删除了" + a + "条");
		resp.sendRedirect(req.getContextPath() + "/ShowEmployee");
	}
}
